<?php
include 'functions.php';
mysql_connect("localhost","tftpot_ryan","Kl14ein86");
mysql_select_db("tftpot_tftp");
$parameters = json_decode(file_get_contents("php://input"));
if(authenticated($parameters)==true){
	$stallNumberQuery = mysql_query("select * from tftpot_tftp.Stalls where Stalls.name = '".$parameters -> {'stallName'}."'");
	while($stall=mysql_fetch_array($stallNumberQuery)){
		$stallNumber = $stall['stall'];
	}
	$q=mysql_query("insert into tftpot_tftp.Thoughts (thought,shitter,timeStamp,stall) values ('" .mysql_real_escape_string($parameters->{'thought'}). "','".mysql_real_escape_string($parameters->{'shitter'}). "', CURRENT_TIMESTAMP(), ".$stallNumber.")");
	$result = array('success' => 'true');
	print(json_encode($result));
	mysql_close();
}
else{
	$result = array('success' => 'false', 'error'=>'error');
	print(json_encode($result));
	mysql_close();
}

?>
